@@ -4,7 +4,7 @@ import { Argument, Command } from "commander";
44import { relative } from "node:path" ;
55import ora , { Ora } from "ora" ;
66
7- import { getApp , getOrg } from "../services/bootstrap.js" ;
7+ import { App , getApp , getOrg } from "../services/bootstrap.js" ;
88import {
99 createFeature ,
1010 Feature ,
@@ -54,7 +54,14 @@ export const createFeatureAction = async (
5454 if ( ! appId ) {
5555 return handleError ( new MissingAppIdError ( ) , "Features Create" ) ;
5656 }
57- const app = getApp ( appId ) ;
57+
58+ let app : App ;
59+ try {
60+ app = getApp ( appId ) ;
61+ } catch ( error ) {
62+ return handleError ( error , "Features Create" ) ;
63+ }
64+
5865 const production = app . environments . find ( ( e ) => e . isProduction ) ;
5966
6067 try {
@@ -102,13 +109,13 @@ export const listFeaturesAction = async () => {
102109 if ( ! appId ) {
103110 return handleError ( new MissingAppIdError ( ) , "Features Create" ) ;
104111 }
105- const app = getApp ( appId ) ;
106- const production = app . environments . find ( ( e ) => e . isProduction ) ;
107- if ( ! production ) {
108- return handleError ( new MissingEnvIdError ( ) , "Features Types" ) ;
109- }
110112
111113 try {
114+ const app = getApp ( appId ) ;
115+ const production = app . environments . find ( ( e ) => e . isProduction ) ;
116+ if ( ! production ) {
117+ return handleError ( new MissingEnvIdError ( ) , "Features Types" ) ;
118+ }
112119 spinner = ora (
113120 `Loading features of app ${ chalk . cyan ( app . name ) } ${ baseUrlSuffix ( baseUrl ) } ...` ,
114121 ) . start ( ) ;
@@ -142,7 +149,13 @@ export const generateTypesAction = async () => {
142149 return handleError ( new MissingAppIdError ( ) , "Features Types" ) ;
143150 }
144151
145- const app = getApp ( appId ) ;
152+ let app : App ;
153+ try {
154+ app = getApp ( appId ) ;
155+ } catch ( error ) {
156+ return handleError ( error , "Features Types" ) ;
157+ }
158+
146159 const production = app . environments . find ( ( e ) => e . isProduction ) ;
147160 if ( ! production ) {
148161 return handleError ( new MissingEnvIdError ( ) , "Features Types" ) ;
@@ -161,8 +174,7 @@ export const generateTypesAction = async () => {
161174 ) ;
162175 } catch ( error ) {
163176 spinner ?. fail ( "Loading features failed." ) ;
164- void handleError ( error , "Features Types" ) ;
165- return ;
177+ return handleError ( error , "Features Types" ) ;
166178 }
167179
168180 try {
@@ -202,7 +214,13 @@ export const featureAccessAction = async (
202214 return handleError ( new MissingAppIdError ( ) , "Feature Access" ) ;
203215 }
204216
205- const app = getApp ( appId ) ;
217+ let app : App ;
218+ try {
219+ app = getApp ( appId ) ;
220+ } catch ( error ) {
221+ return handleError ( error , "Features Types" ) ;
222+ }
223+
206224 const production = app . environments . find ( ( e ) => e . isProduction ) ;
207225 if ( ! production ) {
208226 return handleError ( new MissingEnvIdError ( ) , "Feature Access" ) ;
0 commit comments