@@ -19,6 +19,7 @@ import type {
1919 EnvListTarget ,
2020 EnvListResult ,
2121 EnvRmResult ,
22+ EnvResolvedContext ,
2223 EnvScopeDescriptor ,
2324 EnvUpdateResult ,
2425} from "../types/app-env" ;
@@ -92,14 +93,14 @@ export async function runEnvAdd(
9293 }
9394
9495 const input = await resolveEnvWriteInput ( context , source , "add" ) ;
95- const { client, projectId } = await requireClientAndProject ( context , flags . projectRef , "project env add" ) ;
96+ const { client, projectId, verboseContext } = await requireClientAndProject ( context , flags . projectRef , "project env add" ) ;
9697 const resolved = await resolveScopeToApi ( client , projectId , scope , {
9798 createBranchIfMissing : true ,
9899 signal : context . runtime . signal ,
99100 } ) ;
100101
101102 if ( input . kind === "file" ) {
102- return runEnvAddFile ( context , client , projectId , resolved , input . filePath , input . assignments ) ;
103+ return runEnvAddFile ( context , client , projectId , resolved , input . filePath , input . assignments , verboseContext ) ;
103104 }
104105
105106 const existing = await findVariableByNaturalKey ( client , projectId , input . key , resolved , context . runtime . signal ) ;
@@ -121,7 +122,6 @@ export async function runEnvAdd(
121122 const warnings =
122123 scope . kind === "branch" &&
123124 ! ( await findVariableByNaturalKey ( client , projectId , input . key , {
124- scope : { kind : "role" , role : "preview" } ,
125125 descriptor : { kind : "role" , role : "preview" } ,
126126 apiTarget : { class : "preview" , branchId : null } ,
127127 } , context . runtime . signal ) )
@@ -153,6 +153,7 @@ export async function runEnvAdd(
153153 command : "project.env.add" ,
154154 result : {
155155 projectId,
156+ verboseContext,
156157 scope : resolved . descriptor ,
157158 variable : toMetadata ( data . data as RawEnvironmentVariable , resolved . descriptor ) ,
158159 } ,
@@ -179,14 +180,14 @@ export async function runEnvUpdate(
179180 }
180181
181182 const input = await resolveEnvWriteInput ( context , source , "update" ) ;
182- const { client, projectId } = await requireClientAndProject ( context , flags . projectRef , "project env update" ) ;
183+ const { client, projectId, verboseContext } = await requireClientAndProject ( context , flags . projectRef , "project env update" ) ;
183184 const resolved = await resolveScopeToApi ( client , projectId , scope , {
184185 createBranchIfMissing : false ,
185186 signal : context . runtime . signal ,
186187 } ) ;
187188
188189 if ( input . kind === "file" ) {
189- return runEnvUpdateFile ( context , client , projectId , resolved , input . filePath , input . assignments ) ;
190+ return runEnvUpdateFile ( context , client , projectId , resolved , input . filePath , input . assignments , verboseContext ) ;
190191 }
191192
192193 const existing = await findVariableByNaturalKey ( client , projectId , input . key , resolved , context . runtime . signal ) ;
@@ -221,6 +222,7 @@ export async function runEnvUpdate(
221222 command : "project.env.update" ,
222223 result : {
223224 projectId,
225+ verboseContext,
224226 scope : resolved . descriptor ,
225227 variable : toMetadata ( data . data as RawEnvironmentVariable , resolved . descriptor ) ,
226228 } ,
@@ -301,8 +303,8 @@ export async function runEnvList(
301303) : Promise < CommandSuccess < EnvListResult > > {
302304 const explicit = resolveEnvScope ( flags , { requireExplicit : false , command : "list" } ) ;
303305
304- const { client, projectId } = await requireClientAndProject ( context , flags . projectRef , "project env list" ) ;
305- const resolved = await resolveListScopeToApi ( client , projectId , explicit , {
306+ const { client, projectId, verboseContext } = await requireClientAndProject ( context , flags . projectRef , "project env list" ) ;
307+ const resolved = await resolveListScopeToApi ( client , projectId , explicit ?? undefined , {
306308 cwd : context . runtime . cwd ,
307309 signal : context . runtime . signal ,
308310 } ) ;
@@ -318,6 +320,7 @@ export async function runEnvList(
318320 command : "project.env.list" ,
319321 result : {
320322 projectId,
323+ verboseContext,
321324 scope : resolved . descriptor ,
322325 target : resolved . target ,
323326 variables : variables . map ( ( row ) => toMetadata ( row , resolved . descriptor ) ) ,
@@ -355,7 +358,7 @@ export async function runEnvRemove(
355358 ) ;
356359 }
357360
358- const { client, projectId } = await requireClientAndProject ( context , flags . projectRef , "project env remove" ) ;
361+ const { client, projectId, verboseContext } = await requireClientAndProject ( context , flags . projectRef , "project env remove" ) ;
359362 const resolved = await resolveScopeToApi ( client , projectId , scope , {
360363 createBranchIfMissing : false ,
361364 signal : context . runtime . signal ,
@@ -390,6 +393,7 @@ export async function runEnvRemove(
390393 command : "project.env.remove" ,
391394 result : {
392395 projectId,
396+ verboseContext,
393397 scope : resolved . descriptor ,
394398 key,
395399 } ,
@@ -402,7 +406,7 @@ async function requireClientAndProject(
402406 context : CommandContext ,
403407 explicitProject : string | undefined ,
404408 commandName : string ,
405- ) : Promise < { client : ManagementApiClient ; projectId : string } > {
409+ ) : Promise < { client : ManagementApiClient ; projectId : string ; verboseContext : EnvResolvedContext } > {
406410 const authState = await requireAuthenticatedAuthState ( context ) ;
407411 const client = await requireComputeAuth ( context . runtime . env , context . runtime . signal ) ;
408412 if ( ! client ) {
@@ -420,7 +424,15 @@ async function requireClientAndProject(
420424 commandName,
421425 } ) ;
422426
423- return { client, projectId : target . project . id } ;
427+ return {
428+ client,
429+ projectId : target . project . id ,
430+ verboseContext : {
431+ workspace : authState . workspace ,
432+ project : target . project ,
433+ resolution : target . resolution ,
434+ } ,
435+ } ;
424436}
425437
426438async function resolveScopeToApi (
0 commit comments