@@ -3,16 +3,15 @@ import {
33 FaucetConfig ,
44 Relayer ,
55 Script ,
6- StarshipConfig
6+ StarshipConfig ,
7+ Exposer
78} from '@starship-ci/types' ;
89import * as fs from 'fs' ;
910import * as yaml from 'js-yaml' ;
1011import * as path from 'path' ;
1112
1213import { TemplateHelpers } from './helpers' ;
13- import { DefaultsConfig , ProcessedChain } from './types' ;
14-
15- export { ProcessedChain } ;
14+ import { DefaultsConfig } from './types' ;
1615
1716/**
1817 * Deep merge utility for nested objects
@@ -125,6 +124,96 @@ export class DefaultsManager {
125124 return this . defaultsData . defaultCometmock || { } ;
126125 }
127126
127+ /**
128+ * Process explorer configuration by merging with defaults
129+ */
130+ processExplorer ( explorerConfig ?: any ) : any {
131+ if ( ! explorerConfig ) return undefined ;
132+
133+ const defaultExplorer = this . defaultsData . explorer || { } ;
134+ return deepMerge ( defaultExplorer , explorerConfig ) ;
135+ }
136+
137+ /**
138+ * Process registry configuration by merging with defaults
139+ */
140+ processRegistry ( registryConfig ?: any ) : any {
141+ if ( ! registryConfig ) return undefined ;
142+
143+ const defaultRegistry = this . defaultsData . registry || { } ;
144+ return deepMerge ( defaultRegistry , registryConfig ) ;
145+ }
146+
147+ /**
148+ * Process faucet configuration by merging with defaults
149+ */
150+ processFaucet ( faucetConfig ?: any ) : any {
151+ if ( ! faucetConfig ) return undefined ;
152+
153+ const defaultFaucet = this . defaultsData . faucet || { } ;
154+ return deepMerge ( defaultFaucet , faucetConfig ) ;
155+ }
156+
157+ /**
158+ * Process monitoring configuration by merging with defaults
159+ */
160+ processMonitoring ( monitoringConfig ?: any ) : any {
161+ if ( ! monitoringConfig ) return undefined ;
162+
163+ const defaultMonitoring = this . defaultsData . monitoring || { } ;
164+ return deepMerge ( defaultMonitoring , monitoringConfig ) ;
165+ }
166+
167+ /**
168+ * Process ingress configuration by merging with defaults
169+ */
170+ processIngress ( ingressConfig ?: any ) : any {
171+ if ( ! ingressConfig ) return undefined ;
172+
173+ const defaultIngress = this . defaultsData . ingress || { } ;
174+ return deepMerge ( defaultIngress , ingressConfig ) ;
175+ }
176+
177+ /**
178+ * Process exposer configuration by merging with defaults
179+ */
180+ processExposer ( exposerConfig ?: Exposer ) : Exposer {
181+ if ( ! exposerConfig ) return undefined ;
182+
183+ const defaultExposer = this . defaultsData . exposer || { } ;
184+ return deepMerge ( defaultExposer , exposerConfig ) ;
185+ }
186+
187+ /**
188+ * Process images configuration by merging with defaults
189+ */
190+ processImages ( imagesConfig ?: any ) : any {
191+ if ( ! imagesConfig ) return undefined ;
192+
193+ const defaultImages = this . defaultsData . images || { } ;
194+ return deepMerge ( defaultImages , imagesConfig ) ;
195+ }
196+
197+ /**
198+ * Process resources configuration by merging with defaults
199+ */
200+ processResources ( resourcesConfig ?: any ) : any {
201+ if ( ! resourcesConfig ) return undefined ;
202+
203+ const defaultResources = this . defaultsData . resources || { } ;
204+ return deepMerge ( defaultResources , resourcesConfig ) ;
205+ }
206+
207+ /**
208+ * Process timeouts configuration by merging with defaults
209+ */
210+ processTimeouts ( timeoutsConfig ?: any ) : any {
211+ if ( ! timeoutsConfig ) return undefined ;
212+
213+ const defaultTimeouts = this . defaultsData . timeouts || { } ;
214+ return deepMerge ( defaultTimeouts , timeoutsConfig ) ;
215+ }
216+
128217 /**
129218 * Process a relayer configuration by merging with defaults
130219 * This handles partial overrides properly using deep merge
@@ -230,25 +319,39 @@ export class DefaultsManager {
230319
231320/**
232321 * Apply defaults to a StarshipConfig
233- * This is a standalone function that processes all chains and returns a fully configured StarshipConfig
322+ * This is a standalone function that processes all chains, relayers, and global configs
234323 */
235324export function applyDefaults ( config : StarshipConfig ) : StarshipConfig {
236325 const defaultsManager = new DefaultsManager ( ) ;
237- const processedChains = config . chains ?. map ( ( chain : Chain ) =>
326+
327+ // Process chains with defaults
328+ const processedChains : Chain [ ] = config . chains ?. map ( ( chain : Chain ) =>
238329 defaultsManager . processChain ( chain )
239330 ) ;
240331
241- const processedConfig : StarshipConfig = {
242- ...config ,
243- chains : processedChains
244- } ;
245-
332+ // Process relayers with defaults
333+ let processedRelayers : Relayer [ ] | undefined ;
246334 if ( config . relayers && config . relayers ?. length > 0 ) {
247- const processedRelayers = config . relayers . map ( ( relayer : Relayer ) =>
335+ processedRelayers = config . relayers . map ( ( relayer : Relayer ) =>
248336 defaultsManager . processRelayer ( relayer )
249337 ) ;
250- processedConfig . relayers = processedRelayers ;
251338 }
252339
340+ // Process global configurations individually to maintain type safety
341+ const processedConfig = {
342+ ...config ,
343+ chains : processedChains ,
344+ relayers : processedRelayers ,
345+ ...( config . explorer && { explorer : defaultsManager . processExplorer ( config . explorer ) } ) ,
346+ ...( config . registry && { registry : defaultsManager . processRegistry ( config . registry ) } ) ,
347+ ...( config . faucet && { faucet : defaultsManager . processFaucet ( config . faucet ) } ) ,
348+ ...( config . monitoring && { monitoring : defaultsManager . processMonitoring ( config . monitoring ) } ) ,
349+ ...( config . ingress && { ingress : defaultsManager . processIngress ( config . ingress ) } ) ,
350+ ...( config . exposer && { exposer : defaultsManager . processExposer ( config . exposer ) } ) ,
351+ ...( config . images && { images : defaultsManager . processImages ( config . images ) } ) ,
352+ ...( config . resources && { resources : defaultsManager . processResources ( config . resources ) } ) ,
353+ ...( config . timeouts && { timeouts : defaultsManager . processTimeouts ( config . timeouts ) } )
354+ } ;
355+
253356 return processedConfig ;
254357}
0 commit comments