Fix CLI cloud push flows#1614
Conversation
Greptile SummaryThis PR fixes multiple CLI issues with OAuth token handling, staging/regional Cloud endpoint routing, push flow behaviour, and project settings updates.
Confidence Score: 4/5The changes are well-scoped fixes backed by manual staging verification; the two observations are non-blocking edge cases that do not affect the core flows. The token-refresh retry in getCurrentAccount swallows all inner errors and calls removeCurrentSession() even when the refresh itself succeeded — a flaky network on the second account.get() call would silently sign the user out despite holding a fresh token. The parallel Promise.all for settings policy updates fires all requests but discards in-flight results on the first rejection, leaving the project in a partially-applied settings state with no per-field diagnostics. Both are real but low-frequency edge cases in an otherwise clean and well-tested refactor. templates/cli/lib/auth/login.ts (token refresh error handling) and templates/cli/lib/commands/push.ts (parallel settings update rejection semantics) Important Files Changed
|
Summary
This PR fixes several issues found while testing the CLI with OAuth access tokens and staging/regional Cloud projects.
OAuth and token handling
whoami/current-account request as signed out.forceRefreshoption togetValidAccessToken()so callers can explicitly bypass a still-present access token when recovering from guest/unauthorized responses.Cloud region handling
init projectendpoint generation for staging projects by preserving the current Cloud environment host, so staging projects use endpoints such ashttps://syd.stage.cloud.appwrite.io/v1instead of production regional hosts.getCloudEndpointRegion()helper in CLI utils.https://stage.cloud.appwrite.io/...instead ofhttps://syd.stage.cloud.appwrite.io/...._APP_DOMAIN_FUNCTIONSto the project endpoint region, e.g.fra.stage.appwrite.runtosyd.stage.appwrite.run.Push behavior and diagnostics
appwrite push function.push --allresource group errors by rendering per-resource-group failures instead of concatenating messages into a single line.push --all, so users are not prompted about sites before settings/tables/etc. run.Project settings push
push --allsettings time.0asnullin generated config and when pushing settings, matching API docs wherenulldisables these limits.nullforlimit,sessionsLimit, andpasswordHistoryin CLI config validation.Config handling
_addDBEntity()soinit tablesdbcan add DB entities when the target config array does not exist yet.Testing
php example.php cli.npm run build:runtimefromexamples/cli.domain_owned_by_different_organizationwhen the manager-region suffix is used against the regional API.Notes
examples/cliis ignored in this checkout, so this PR contains the CLI template changes. The generated CLI was still regenerated and built locally for verification.