@@ -9,41 +9,47 @@ import type { ApiService } from "../api"
99import { AUTH_PROVIDER_ID } from "../auth"
1010import type { ConfigService } from "../config"
1111import {
12+ type App ,
1213 type Config ,
1314 type Deployment ,
1415 DeploymentStatus ,
1516 failedStatuses ,
1617 statusMessages ,
1718} from "../types"
18- import { createOrLinkApp } from "../ui/pickers"
19+ import { ui } from "../ui/dialogs"
20+ import { createNewApp , pickExistingApp , pickTeam } from "../ui/pickers"
1921
2022// Exclusion patterns - aligned with fastapi-cloud-cli
2123// See: https://github.com/fastapilabs/fastapi-cloud-cli/blob/main/src/fastapi_cloud_cli/commands/deploy.py
22- const EXCLUDE_DIRS = new Set ( [
24+ const EXCLUDE_PARTS = [
2325 ".venv" ,
2426 "__pycache__" ,
2527 ".mypy_cache" ,
2628 ".pytest_cache" ,
2729 ".git" ,
28- ] )
29- const EXCLUDE_FILES = new Set ( [ ".gitignore" , ".fastapicloudignore" ] )
30+ ".gitignore" ,
31+ ".fastapicloudignore" ,
32+ ]
3033
3134// 300 attempts x 2 seconds = 10 minutes maximum
3235const MAX_POLL_ATTEMPTS = 300
3336const DEPLOYMENT_POLL_INTERVAL_MS = 2000
3437
3538export function shouldExclude ( relativePath : string ) : boolean {
3639 const parts = relativePath . split ( "/" )
37- const fileName = parts [ parts . length - 1 ]
3840
39- // Check if any path component is in exclude list
40- for ( const part of parts ) {
41- if ( EXCLUDE_DIRS . has ( part ) ) return true
41+ if ( parts . some ( ( part ) => EXCLUDE_PARTS . includes ( part ) ) ) {
42+ return true
43+ }
44+
45+ if ( relativePath . endsWith ( ".pyc" ) ) {
46+ return true
4247 }
4348
44- // Check file-level exclusions
45- if ( EXCLUDE_FILES . has ( fileName ) ) return true
46- if ( fileName . endsWith ( ".pyc" ) ) return true
49+ const fileName = parts [ parts . length - 1 ]
50+ if ( fileName === ".env" || fileName . startsWith ( ".env." ) ) {
51+ return true
52+ }
4753
4854 return false
4955}
@@ -59,7 +65,7 @@ export async function deploy(context: DeployContext): Promise<boolean> {
5965 const { workspaceRoot, configService, apiService, statusBarItem } = context
6066
6167 if ( ! workspaceRoot ) {
62- vscode . window . showErrorMessage ( "No workspace folder open" )
68+ ui . showErrorMessage ( "No workspace folder open" )
6369 return false
6470 }
6571
@@ -71,7 +77,7 @@ export async function deploy(context: DeployContext): Promise<boolean> {
7177 silent : true ,
7278 } )
7379 if ( ! session ) {
74- const result = await vscode . window . showErrorMessage (
80+ const result = await ui . showErrorMessage (
7581 "Please sign in to FastAPI Cloud first." ,
7682 "Sign In" ,
7783 )
@@ -84,11 +90,38 @@ export async function deploy(context: DeployContext): Promise<boolean> {
8490 const existingConfig = await configService . getConfig ( workspaceRoot )
8591 const config : Config = existingConfig ?? { app_id : "" , team_id : "" }
8692 if ( ! config . app_id ) {
87- const app = await createOrLinkApp ( apiService , workspaceRoot )
93+ const team = await pickTeam ( apiService )
94+ if ( ! team ) return false
95+
96+ const choice = await ui . showQuickPick (
97+ [
98+ {
99+ label : "$(link) Link Existing App" ,
100+ description : "Connect to an app on FastAPI Cloud" ,
101+ id : "link" ,
102+ } ,
103+ {
104+ label : "$(add) Create New App" ,
105+ description : "Create a new app and link it" ,
106+ id : "create" ,
107+ } ,
108+ ] ,
109+ { placeHolder : "Set up FastAPI Cloud" } ,
110+ )
111+ if ( ! choice ) return false
112+
113+ let app : App | null
114+ if ( choice . id === "create" ) {
115+ const folderName = workspaceRoot . path . split ( "/" ) . pop ( ) || "my-app"
116+ app = await createNewApp ( apiService , team , folderName )
117+ } else {
118+ app = await pickExistingApp ( apiService , team )
119+ }
88120 if ( ! app ) return false
89- config . app_id = app . app . id
90- config . team_id = app . team . id
91- config . app_slug = app . app . slug
121+
122+ config . app_id = app . id
123+ config . team_id = team . id
124+ config . app_slug = app . slug
92125 await configService . writeConfig ( workspaceRoot , config )
93126 }
94127
@@ -116,7 +149,7 @@ export async function deploy(context: DeployContext): Promise<boolean> {
116149 )
117150
118151 if ( result ) {
119- const action = await vscode . window . showInformationMessage (
152+ const action = await ui . showInformationMessage (
120153 "Deployed successfully!" ,
121154 "Open App" ,
122155 "View Dashboard" ,
0 commit comments