@@ -247,3 +247,49 @@ export const metadataExport = async (options, program) => {
247247 . then ( ( ) => { } )
248248 . catch ( CLIErrorHandler ( program ) ) ;
249249} ;
250+
251+ export const metadataSync = async ( options , program ) => {
252+ await ( async ( ) => {
253+ const cwd = path . resolve ( process . cwd ( ) ) ;
254+ console . log ( 'Executing in cwd:' . green , `${ cwd } ` . yellow ) ;
255+
256+ // Load yaml configuration
257+ const configuration = await loadConfigFromYAML ( options ) ;
258+
259+ const endpoint = configuration ?. endpoint ?? 'http://localhost:8081' ;
260+ const adminSecret = options ?. adminSecret ?? configuration ?. admin_secret ?? '' ;
261+
262+ const headers = {
263+ 'x-hlambda-admin-secret' : adminSecret ,
264+ } ;
265+ const response = await fetch ( `${ endpoint } /console/api/v1/metadata/sync` , {
266+ method : 'GET' ,
267+ // body: formData,
268+ headers,
269+ } ) ;
270+
271+ if ( response . status === 200 ) {
272+ console . log ( 'Metadata synced!' . green ) ;
273+ }
274+ console . log ( response . status ) ;
275+
276+ if ( response . status !== 200 ) {
277+ throw new Error ( errors . ERROR_INVALID_HLAMBDA_ADMIN_SECRET ) ;
278+ }
279+
280+ // This is magic from commander, the real flag was --no-auto-reload but we get positive logic transformation to autoReload
281+ if ( options ?. autoReload ) {
282+ const responseRestart = await fetch ( `${ endpoint } /console/api/v1/trigger-restart` , {
283+ method : 'GET' ,
284+ // body: formData,
285+ headers,
286+ } ) ;
287+ if ( responseRestart . status === 200 ) {
288+ console . log ( 'Metadata reloaded after clearing!' . green ) ;
289+ }
290+ console . log ( responseRestart . status ) ;
291+ }
292+ } ) ( )
293+ . then ( ( ) => { } )
294+ . catch ( CLIErrorHandler ( program ) ) ;
295+ } ;
0 commit comments