File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import { nodeGenerator } from './generators/node/index.js';
99import { addOAuth } from './subcommands/addOAuth.js' ;
1010import { addAppExtension } from './subcommands/addAppExtension.js' ;
1111import type { AppExtensionType } from './generators/interface.js' ;
12+ import { isAppExtensionType } from './generators/interface.js' ;
1213
1314interface NextStepOptions {
1415 nameOrPath : string ;
@@ -59,8 +60,9 @@ export async function dispatchSubcommand(argv: string[]): Promise<boolean> {
5960
6061 if ( subcommand === 'add-app-extension' ) {
6162 const appExtIdx = argv . indexOf ( '--app-extensions' ) ;
62- const appExtensions =
63- appExtIdx !== - 1 ? ( [ argv [ appExtIdx + 1 ] ] as AppExtensionType [ ] ) : undefined ;
63+ const appExtValue = appExtIdx !== - 1 ? argv [ appExtIdx + 1 ] : undefined ;
64+ const appExtensions : AppExtensionType [ ] | undefined =
65+ appExtValue !== undefined && isAppExtensionType ( appExtValue ) ? [ appExtValue ] : undefined ;
6466 await addAppExtension ( outputDir , appExtensions ) ;
6567 return true ;
6668 }
Original file line number Diff line number Diff line change 11export type Database = 'postgres' | 'mysql' | 'sqlite' ;
2- export type AppExtensionType = 'custom-panel' | 'custom-modal' ;
2+
3+ export const APP_EXTENSION_TYPES = [ 'custom-panel' , 'custom-modal' ] as const ;
4+ export type AppExtensionType = ( typeof APP_EXTENSION_TYPES ) [ number ] ;
5+
6+ export function isAppExtensionType ( value : string ) : value is AppExtensionType {
7+ return ( APP_EXTENSION_TYPES as readonly string [ ] ) . includes ( value ) ;
8+ }
39
410export interface GeneratorOptions {
511 projectName : string ;
You can’t perform that action at this time.
0 commit comments