@@ -103,18 +103,24 @@ export class EnkryptifyProvider implements Provider {
103103 throw new Error ( "No workspaces found. Please create a workspace first before setting up." ) ;
104104 }
105105
106- const workspaceSlug = await selectName (
107- workspaces . map ( ( ws ) => `${ ws . slug } ` ) ,
108- "Select workspace" ,
109- ) ;
106+ const workspaceMap = new Map < string , Workspace > ( ) ;
107+ const workspaceLabels = workspaces . map ( ( ws ) => {
108+ const label = `${ ws . name } (${ ws . slug } )` ;
109+ workspaceMap . set ( label , ws ) ;
110+ return label ;
111+ } ) ;
110112
111- if ( ! workspaceSlug ) throw new Error ( "Failed to select workspace") ;
113+ const selectedWorkspaceLabel = await selectName ( workspaceLabels , "Select workspace") ;
112114
113- const selectedWorkspace = workspaces . find ( ( ws ) => ws . slug === workspaceSlug ) ;
115+ if ( ! selectedWorkspaceLabel ) throw new Error ( "Failed to select workspace" ) ;
116+
117+ const selectedWorkspace = workspaceMap . get ( selectedWorkspaceLabel ) ;
114118 if ( ! selectedWorkspace ) {
115119 throw new Error ( "Failed to find selected workspace" ) ;
116120 }
117121
122+ const workspaceSlug = selectedWorkspace . slug ;
123+
118124 const projectsResponse = await this . fetchResource < ProjectTeam > ( `/v1/workspace/${ workspaceSlug } /project` ) ;
119125
120126 const allProjects : Project [ ] = [ ] ;
@@ -130,18 +136,24 @@ export class EnkryptifyProvider implements Provider {
130136 ) ;
131137 }
132138
133- const projectSlug = await selectName (
134- allProjects . map ( ( p ) => p . slug ) ,
135- "Select project" ,
136- ) ;
139+ const projectMap = new Map < string , Project > ( ) ;
140+ const projectLabels = allProjects . map ( ( p ) => {
141+ const label = `${ p . name } (${ p . slug } )` ;
142+ projectMap . set ( label , p ) ;
143+ return label ;
144+ } ) ;
137145
138- if ( ! projectSlug ) throw new Error ( "Failed to select project") ;
146+ const selectedProjectLabel = await selectName ( projectLabels , "Select project") ;
139147
140- const selectedProject = allProjects . find ( ( p ) => p . slug === projectSlug ) ;
148+ if ( ! selectedProjectLabel ) throw new Error ( "Failed to select project" ) ;
149+
150+ const selectedProject = projectMap . get ( selectedProjectLabel ) ;
141151 if ( ! selectedProject ) {
142152 throw new Error ( "Failed to find selected project" ) ;
143153 }
144154
155+ const projectSlug = selectedProject . slug ;
156+
145157 const environments = await this . fetchResource < Environment > (
146158 `/v1/workspace/${ workspaceSlug } /project/${ projectSlug } /environment` ,
147159 ) ;
0 commit comments