@@ -6,6 +6,7 @@ import { dirname, isAbsolute, join, relative } from "node:path";
66import ora , { Ora } from "ora" ;
77
88import { createFeature , Feature , listFeatures } from "../services/features.js" ;
9+ import { listStages , Stage } from "../services/stages.js" ;
910import { configStore } from "../stores/config.js" ;
1011import { handleError , MissingAppIdError } from "../utils/errors.js" ;
1112import { genFeatureKey , genTypes , KeyFormatPatterns } from "../utils/gen.js" ;
@@ -33,7 +34,7 @@ export const createFeatureAction = async (
3334 if ( ! name ) {
3435 name = await input ( {
3536 message : "New feature name:" ,
36- validate : ( text ) => text . length > 0 || "Name is required" ,
37+ validate : ( text ) => text . length > 0 || "Name is required. " ,
3738 } ) ;
3839 }
3940
@@ -55,7 +56,7 @@ export const createFeatureAction = async (
5556 `Created feature ${ chalk . cyan ( feature . name ) } with key ${ chalk . cyan ( feature . key ) } at ${ chalk . cyan ( baseUrl ) } . 🎉` ,
5657 ) ;
5758 } catch ( error ) {
58- spinner ?. fail ( "Feature creation failed" ) ;
59+ spinner ?. fail ( "Feature creation failed. " ) ;
5960 void handleError ( error , "Features Create" ) ;
6061 }
6162} ;
@@ -71,11 +72,17 @@ export const listFeaturesAction = async () => {
7172 ) . start ( ) ;
7273 const features = await listFeatures ( appId ) ;
7374 spinner . succeed (
74- `Loaded features of app ${ chalk . cyan ( appId ) } at ${ chalk . cyan ( baseUrl ) } ` ,
75+ `Loaded features of app ${ chalk . cyan ( appId ) } at ${ chalk . cyan ( baseUrl ) } .` ,
76+ ) ;
77+ console . table (
78+ features . map ( ( { key, name, stage } ) => ( {
79+ key,
80+ name,
81+ stage : stage ?. name ,
82+ } ) ) ,
7583 ) ;
76- console . table ( features ) ;
7784 } catch ( error ) {
78- spinner ?. fail ( "Loading features failed" ) ;
85+ spinner ?. fail ( "Loading features failed. " ) ;
7986 void handleError ( error , "Features List" ) ;
8087 }
8188} ;
@@ -86,6 +93,7 @@ export const generateTypesAction = async () => {
8693
8794 let spinner : Ora | undefined ;
8895 let features : Feature [ ] = [ ] ;
96+ let stages : Stage [ ] = [ ] ;
8997 try {
9098 if ( ! appId ) throw new MissingAppIdError ( ) ;
9199 spinner = ora (
@@ -95,10 +103,20 @@ export const generateTypesAction = async () => {
95103 includeRemoteConfigs : true ,
96104 } ) ;
97105 spinner . succeed (
98- `Loaded features of app ${ chalk . cyan ( appId ) } at ${ chalk . cyan ( baseUrl ) } ` ,
106+ `Loaded features of app ${ chalk . cyan ( appId ) } at ${ chalk . cyan ( baseUrl ) } . ` ,
99107 ) ;
100108 } catch ( error ) {
101- spinner ?. fail ( "Loading features failed" ) ;
109+ spinner ?. fail ( "Loading features failed." ) ;
110+ void handleError ( error , "Features Types" ) ;
111+ return ;
112+ }
113+
114+ try {
115+ spinner = ora ( `Loading stages...` ) . start ( ) ;
116+ stages = await listStages ( appId ) ;
117+ spinner . succeed ( `Loaded stages.` ) ;
118+ } catch ( error ) {
119+ spinner ?. fail ( "Loading stages failed." ) ;
102120 void handleError ( error , "Features Types" ) ;
103121 return ;
104122 }
@@ -109,33 +127,33 @@ export const generateTypesAction = async () => {
109127
110128 // Generate types for each output configuration
111129 for ( const output of typesOutput ) {
112- const types = await genTypes ( features , output . format ) ;
130+ const types = await genTypes ( features , stages , output . format ) ;
113131 const outPath = isAbsolute ( output . path )
114132 ? output . path
115133 : join ( projectPath , output . path ) ;
116134
117135 await mkdir ( dirname ( outPath ) , { recursive : true } ) ;
118136 await writeFile ( outPath , types ) ;
119- spinner . text = `Generated ${ output . format } types for ${ chalk . cyan ( appId ) } in ${ chalk . cyan ( relative ( projectPath , outPath ) ) } .` ;
137+ spinner . succeed (
138+ `Generated ${ output . format } types in ${ chalk . cyan ( relative ( projectPath , outPath ) ) } .` ,
139+ ) ;
120140 }
121141
122- spinner . succeed (
123- `Generated types for ${ chalk . cyan ( appId ) } in ${ typesOutput . length } location(s).` ,
124- ) ;
142+ spinner . succeed ( `Generated types for ${ chalk . cyan ( appId ) } .` ) ;
125143 } catch ( error ) {
126- spinner ?. fail ( "Type generation failed" ) ;
144+ spinner ?. fail ( "Type generation failed. " ) ;
127145 void handleError ( error , "Features Types" ) ;
128146 }
129147} ;
130148
131149export function registerFeatureCommands ( cli : Command ) {
132150 const featuresCommand = new Command ( "features" ) . description (
133- "Manage features" ,
151+ "Manage features. " ,
134152 ) ;
135153
136154 featuresCommand
137155 . command ( "create" )
138- . description ( "Create a new feature" )
156+ . description ( "Create a new feature. " )
139157 . addOption ( appIdOption )
140158 . addOption ( keyFormatOption )
141159 . addOption ( featureKeyOption )
@@ -144,13 +162,13 @@ export function registerFeatureCommands(cli: Command) {
144162
145163 featuresCommand
146164 . command ( "list" )
147- . description ( "List all features" )
165+ . description ( "List all features. " )
148166 . addOption ( appIdOption )
149167 . action ( listFeaturesAction ) ;
150168
151169 featuresCommand
152170 . command ( "types" )
153- . description ( "Generate feature types" )
171+ . description ( "Generate feature types. " )
154172 . addOption ( appIdOption )
155173 . addOption ( typesOutOption )
156174 . addOption ( typesFormatOption )
0 commit comments