|
1 | 1 | import type { RegionCode } from '../constants'; |
2 | 2 | import type { Command, Option } from 'commander'; |
| 3 | +import type { CommandOptions } from '../types'; |
| 4 | +import type { PullComponentsOptions } from '../commands/components/pull/constants'; |
| 5 | +import type { PushComponentsOptions } from '../commands/components/push/constants'; |
| 6 | +import type { PullDatasourcesOptions } from '../commands/datasources/pull/constants'; |
| 7 | +import type { PushDatasourcesOptions } from '../commands/datasources/push/constants'; |
| 8 | +import type { MigrationsGenerateOptions } from '../commands/migrations/generate/constants'; |
| 9 | +import type { MigrationsRunOptions } from '../commands/migrations/run/constants'; |
| 10 | +import type { GenerateTypesOptions } from '../commands/types/generate/constants'; |
3 | 11 |
|
4 | 12 | export type PlainObject = Record<string, any>; |
5 | 13 |
|
@@ -41,6 +49,59 @@ export interface ResolvedCliConfig extends GlobalConfig { |
41 | 49 | [key: string]: any; |
42 | 50 | } |
43 | 51 |
|
| 52 | +type StripCommandOption<T> = T extends CommandOptions ? Omit<T, keyof CommandOptions> : T; |
| 53 | +type CommandConfig<T> = Partial<StripCommandOption<T>>; |
| 54 | + |
| 55 | +export interface ComponentsModuleConfig extends Record<string, unknown> { |
| 56 | + space?: string; |
| 57 | + path?: string; |
| 58 | + pull?: CommandConfig<PullComponentsOptions>; |
| 59 | + push?: CommandConfig<PushComponentsOptions>; |
| 60 | +} |
| 61 | + |
| 62 | +export interface DatasourcesModuleConfig extends Record<string, unknown> { |
| 63 | + space?: string; |
| 64 | + path?: string; |
| 65 | + pull?: CommandConfig<PullDatasourcesOptions>; |
| 66 | + push?: CommandConfig<PushDatasourcesOptions>; |
| 67 | +} |
| 68 | + |
| 69 | +export interface MigrationsModuleConfig extends Record<string, unknown> { |
| 70 | + space?: string; |
| 71 | + path?: string; |
| 72 | + generate?: CommandConfig<MigrationsGenerateOptions>; |
| 73 | + run?: CommandConfig<MigrationsRunOptions>; |
| 74 | +} |
| 75 | + |
| 76 | +export interface TypesModuleConfig extends Record<string, unknown> { |
| 77 | + space?: string; |
| 78 | + path?: string; |
| 79 | + generate?: CommandConfig<GenerateTypesOptions>; |
| 80 | +} |
| 81 | + |
| 82 | +export type ModulesConfig = Record<string, PlainObject> & { |
| 83 | + components?: ComponentsModuleConfig; |
| 84 | + datasources?: DatasourcesModuleConfig; |
| 85 | + migrations?: MigrationsModuleConfig; |
| 86 | + types?: TypesModuleConfig; |
| 87 | +}; |
| 88 | + |
| 89 | +export type DeepPartial<T> = { |
| 90 | + [K in keyof T]?: T[K] extends (...args: any[]) => any |
| 91 | + ? T[K] |
| 92 | + : T[K] extends object |
| 93 | + ? DeepPartial<T[K]> |
| 94 | + : T[K]; |
| 95 | +}; |
| 96 | + |
| 97 | +export interface StoryblokConfig extends DeepPartial<GlobalConfig> { |
| 98 | + modules?: ModulesConfig; |
| 99 | +} |
| 100 | + |
| 101 | +export function defineConfig<T extends StoryblokConfig>(config: T): T { |
| 102 | + return config; |
| 103 | +} |
| 104 | + |
44 | 105 | export type OptionParser<T> = (value: string, previous?: T) => T; |
45 | 106 |
|
46 | 107 | export interface GlobalOptionDefinition<T = unknown> { |
|
0 commit comments